/*
 * @(#)Main.java	1.00 10/06/21
 *
 * Copyright 2010 Kmdigit, Inc. All rights reserved.
 * KMdigit PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

package kmdigit.hello;

import java.io.IOException;
import java.io.Reader;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

/**
 * @author  Kyunam Lee
 * @version 1.00, 06/21/10
 */
public class Main {
	public static void main(String[] args) throws IOException, SQLException {
		String resource = "SqlMapConfig.xml";
		Reader reader = Resources.getResourceAsReader(resource);
		SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
		List list = sqlMap.queryForList("getAllUsers", "EMPLOYEE");
		
		System.out.println("Selected" + list.size() + " records");
		for (int i=0; i<list.size(); i++)
			System.out.println(list.get(i));
		
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("username", "test");
		map.put("password", "111");
		map.put("groupname", "EMPLOYEE");
		sqlMap.insert("insertUser", map);
	}
}
